
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="__STATIC__/admin/news/css/index.css">
    <link rel="stylesheet" href="__STATIC__/admin/layui/css/layui.css">
    <title>Document</title>
    <style>
        .anzhuang{
            color: red;
        }
        .shouxin{
            cursor: pointer;
        }
    </style>
</head>
<body>
<div class="container_index" style="background-image: url('__STATIC__/admin/news/img/2103dbf798c03a6c8af9463b8bd12be.jpg');background-size:cover">
    <div class="index_first">
        {foreach $modular as $value}
        <div class="index_one">
            <div class="myindex">
                <div class="title_img">
                    {if isset($value['img'])&&$value['img']}
                    <img src="{$value['img']}" width="69" height="69" alt="">
                    {else}
                    <img src="/static/home/img/error.png" width="69" height="69" alt="">
                    {/if}
                </div>
                <div class="title_span">
                    <span>{$value['name']}</span>
                </div>
            </div>
            <div class="myitem">
                <span>项目模块:</span>
                <span>{$value['dir']}</span>
            </div>
            <div class="myitem">
                <span>项目作者:</span>
                <span>{$value['author']}</span>
            </div>
            <div class="enter">
                {if isset($value['install'])&&$value['install']=='1'}
                <input class="shouxin" type="button" data-href="{:url('admin/index/signin?modular='.$value['dir'])}" onclick="jinru(this)" value="进入">
                {else}
                <input type="button" class="anzhuang shouxin" data-model="{$value['dir']}" value="安装">
                {/if}
            </div>
        </div>
        {/foreach}
        <div class="index_img">
            <img onclick="tianjia()" src="__STATIC__/admin/news/img/8799f1e7c47ff33d0d0a68217285710.png" alt="">
        </div>
    </div>
</div>
<script src="__STATIC__/admin/js/jquery-2.2.3.min.js"></script>
<script src="__STATIC__/admin/layui/layui.all.js"></script>
<script>
    //点击进入
    function jinru(obj) {
        var href = $(obj).attr('data-href');
        window.location.href = href;
    }
    /**
     * 点击添加
     */
    function tianjia() {
        layer.open({
            type: 2,
            title: '添加项目',
            shadeClose: true,
            shade: 0.8,
            area: ['500px', '90%'],
            content:"/admin/index/addmodular.html" ,
            end:function () {
                window.location.reload();
            }
        });
    }
    /**
     * 安装
     */
    $(".anzhuang").click(function () {
        var dir = $(this).attr('data-model');
        layer.confirm('确定安装吗？',{
            btn:['确定','取消']
        },function () {
            var index = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
            $.post("{:url('index/install')}",{modular:dir},function (res) {
                layer.close(index);
                if(res.code==200){
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    },1000);
                }else{
                    layer.msg(res.msg);
                }
            })
        })
    })
</script>
</body>
</html>